package com.nettcp;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;



public class TCPFileUploadClient {

	public static void main(String[] args) throws IOException {
	/*步骤一： 发起连接请求*/
		
Socket socket=new Socket("192.168.31.194",1314);
		
		
		
		
		
		
	/* 步骤二： 数据传输 */	
		OutputStream out = socket.getOutputStream();
		FileInputStream in= new FileInputStream("2.jpg");
		byte[] buffer = new byte[1024];
		
		int len = 0;
		while((len = in.read(buffer))!= -1){
			out.write(buffer,0,len);
		}
		in.close();
		out.close();
		
		
		
		
	}
		
}			
		













		
		/*打印输出接收端收到的字符数据*/
		/*
		Socket socket=new Socket("192.168.31.194",1314);
		
		OutputStream out = socket.getOutputStream();
		FileInputStream in= new FileInputStream("12.jpg");
		byte[] buffer = new byte[1024];
		
		int len = 0;
		while((len = in.read(buffer))!= -1){
			out.write(buffer,0,len);
		}
		
		in.close();
		out.close();
		
		
		*/
	


